using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using Microsoft.DesignerSupport;

namespace XMTAEditor
{
	public partial class EventEditor : BaseEditor
	{
		public EventEditor()
		{
			InitializeComponent();
			editorBrowsable.EnumType = typeof(EditorBrowsableState);
		}

		private EventType ev;

		public EventType Event
		{
			get { return ev; }
			set { ev = value; Fill();  }
		}

		protected override void Fill()
		{
			description.Text = BindUtil.ToText(ev.Description);
			category.Text = BindUtil.ToText(ev.Category);
			editorBrowsable.EnumVal = BindUtil.ToText(ev.EditorBrowsable);
			checkBoxList1.Items[0].State = BindUtil.ToCheck(ev.Browsable);
			checkBoxList1.Items[1].State = BindUtil.ToCheck(ev.Supported);
			checkBoxList1.Refresh();
		}

		public override void Save()
		{
			changed = false;
			ev.Description = BindUtil.ToVar(description.Text);
			ev.Category = BindUtil.ToVar(category.Text);
			ev.EditorBrowsable = BindUtil.ToVar(editorBrowsable.EnumVal);
			ev.Browsable = BindUtil.FromCheck(checkBoxList1.Items[0].State);
			ev.Supported = BindUtil.FromCheck(checkBoxList1.Items[1].State);
		}

		private void EventEditor_Load(object sender, EventArgs e)
		{

		}

		private void description_TextChanged(object sender, EventArgs e)
		{
			changed = true;
		}
	}
}
